{include file='_header'}
<style type="text/css">
.table_kf {display: none;width:100%}
.table_kf.active {display: table;}
</style>
<div class="page-header">
    当前位置：<span class="text-primary">商品管理</span>
</div>
<div class="page-content">
    <form action="" method="get" class="form-horizontal" plugins="form">
        <div class="page-toolbar m-b-sm m-t-sm">
            <div class="col-sm-6">
                <span class='pull-left'>
                    <a class='btn btn-primary btn-sm' href="{:url('admin/auction/goodsadd')}"><i class='fa fa-plus'></i> 添加商品</a>
                </span>
            </div>
            <div class="col-sm-6 pull-right">
                <div class="input-group">
                    <div class="input-group-select">
                        <select name="category" class='form-control' style="width:120px;">
                            <option value="" {if empty($category)}selected{/if} >商品分类</option>
                            {foreach name='categorys' item='cate'}
                            <option value="{$cate['id']}" {if $category==$cate['id']}selected{/if}>{$cate['name']}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="input-group-select">
                        <select name='status' class='form-control  input-sm' style='width:100px;'>
                            <option value='' {if $status==''}selected{/if}>状态</option>
                            <option value='0' {if $status=='0'}selected{/if}>下架</option>
                            <option value='1' {if $status=='1'}selected{/if} >上架</option>
                        </select>
                    </div>
                    <input type="text" class="input-sm form-control" name='keyword' value="{$keyword}" placeholder="请输入关键词">
                    <span class="input-group-btn">
                        <button class="btn btn-primary" type="submit">搜索</button>
                    </span>
                </div>
            </div>
        </div>
        <ul class="nav nav-arrow-next nav-tabs" id="myTab" >
            <li class="{if $type=='sale' || empty($type)}active{/if}" >
                <a href="{:url('admin/auction/goods',array('type'=>sale))}">进行中 (<span class='goods-sale'>-</span>)</a>
            </li>
            <li class="{if $type=='wait'}active{/if}" >
                <a href="{:url('admin/auction/goods',array('type'=>wait))}">待开始 (<span class='goods-wait'>-</span>)</a>
            </li>
            <li class="{if $type=='finish'}active{/if}" >
                <a href="{:url('admin/auction/goods',array('type'=>finish))}">已结束 (<span class='goods-finish'>-</span>)</a>
            </li>
            <li class="{if $type=='auctions'}active{/if}">
                <a href="{:url('admin/auction/goods',array('type'=>auctions))}">已流拍 (<span class='goods-auctions'>-</span>)</a>
            </li>
            <li class="{if $type=='store'}active{/if}">
                <a href="{:url('admin/auction/goods',array('type'=>store))}">已下架 (<span class='goods-store'>-</span>)</a>
            </li>
        </ul>
    </form>
    <form action="" method="post">
        <div class="table_kf active" id="tab_sale">
            {if !empty(count($list))}
            <div class="page-table-header" style="border-top: none">
                <input type="checkbox">
                <div class="btn-group">
                    {if $type=='store'}
                    <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:url('admin/auction/goodsstatus',array('status'=>1))}">
                        <i class='icow icow-shangjia2'></i> 上架
                    </button>
                    {/if}
                    {if $type=='sale' || empty($type)}
                    <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:url('admin/auction/goodsstatus',array('status'=>0))}">
                        <i class='icow icow-xiajia3'></i> 下架
                    </button>
                    {/if}
                    <button class="btn btn-default btn-sm  btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="{:url('admin/auction/goodsdelete')}">
                        <i class='icow icow-shanchu1'></i> 删除
                    </button>
                </div>
            </div>
            <table class="table table-hover table-responsive">
            <thead>
            <tr>
                <th style="width:25px;"></th>
                <th style="width:50px;">排序</th>
                <th style="width:70px;">商品标题</th>
                <th style="width:200px;">&nbsp;</th>
                <th>起拍价格</th>
                <th>加价幅度</th>
                <th>保证金</th>
                <th>当前出价</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th style="width:70px;">状态</th>
                <th style="text-align: center;width: 65px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach name='list' item='row'}
            <tr>
                <td><input type='checkbox' value="{$row['id']}"/></td>
                <td>
                    <a href='javascript:;' data-toggle='ajaxEdit' data-href="{:url('admin/auction/goodsproperty',array('type'=>'displayorder','id'=>$row['id']))}">{$row['displayorder']}</a>
                </td>
                <td><img src="{$row['thumb']}" style="width:40px;height:40px;padding:1px;border:1px solid #ccc;" onerror="this.src='../addons/ewei_shopv2/static/images/nopic.png'"/>
                </td>
                <td>
                    {$row['title']}
                    <br/>
                    <span class='text-primary'>[{$row['name']}]</span>
                </td>
                <td>{$row['shprice']}</td>
                <td>{$row['addprice']}</td>
                <td>{$row['bond']}</td>
                <td>{$row['stprice']}</td>
                <td>{:date('Y-m-d H:i:s',$row['starttime'])}</td>
                <td>{:date('Y-m-d H:i:s',$row['endtime'])}</td>
                <td >
                    <span class='label {if $row['status']==1}label-primary{else}label-default{/if}'
                    data-toggle='ajaxSwitch'
                    data-switch-value='{$row['status']}'
                    data-switch-value0='0|下架|label label-default|{:url('admin/auction/goodsproperty',array('type'=>'status', 'value'=>1,'id'=>$row['id']))}'
                    data-switch-value1='1|上架|label label-primary|{:url('admin/auction/goodsproperty',array('type'=>'status', 'value'=>0,'id'=>$row['id']))}'
                    >{if $row['status']==1}上架{else}下架{/if}</span>
                </td>
                <td >
                    <a class='btn btn-default btn-sm btn-op btn-operation' href="{:url('admin/auction/goodsedit',array('id' => $row['id']));}">
                        <span data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑">
                                <i class='icow icow-bianji2'></i>
                       </span>
                    </a>
                    <a class='btn btn-default btn-sm btn-op btn-operation' data-toggle='ajaxRemove' href="{:url('admin/auction/goodsdelete',array('id' => $row['id']));}" data-confirm="确定要删除该商品吗？">
                        <span data-toggle="tooltip" data-placement="top" title="" data-original-title="删除">
                             <i class='icow icow-shanchu1'></i>
                        </span>
                    </a>
                </td>
            </tr>
            {/foreach}
            </tbody>
            <tfoot>
                <tr>
                    <td><input type="checkbox"></td>
                    <td colspan="3">
                        <div class="btn-group">
                            {if $type=='store'}
                            <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:url('admin/auction/goodsstatus',array('status'=>1))}">
                                <i class='icow icow-shangjia2'></i> 上架
                            </button>
                            {/if}
                            {if $type=='sale' || empty($type)}
                            <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:url('admin/auction/goodsstatus',array('status'=>0))}">
                                <i class='icow icow-xiajia3'></i> 下架
                            </button>
                            {/if}
                            <button class="btn btn-default btn-sm  btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="{:url('admin/auction/goodsdelete')}">
                                <i class='icow icow-shanchu1'></i> 删除
                            </button>
                        </div>
                    </td>
                    <td colspan="8" class="text-right">{$pager}</td>
                </tr>
            </tfoot>
            </table>
            {else}
            <div class='panel panel-default'>
                <div class='panel-body' style='text-align: center;padding:30px;'>暂时没有任何商品</div>
            </div>
            {/if}
        </div>
    </form>
</div>
<script type="text/javascript">
$(function(){
    /*
     * 进行中 1 待开始 2 已结束 3 已流拍 4
     * */
    $.getJSON("{:url('admin/auction/goodstotal');}",{ type: "1"},function(json){
        $(".goods-sale").text(json);
        $.getJSON("{:url('admin/auction/goodstotal');}",{ type: "2"},function(json){
            $(".goods-wait").text(json);
            $.getJSON("{:url('admin/auction/goodstotal');}",{ type: "3"},function(json){
                $(".goods-finish").text(json);
                $.getJSON("{:url('admin/auction/goodstotal');}",{ type: "4"},function(json){
                    $(".goods-auctions").text(json);
                    $.getJSON("{:url('admin/auction/goodstotal');}",{ type: "5"},function(json){
                        $(".goods-store").text(json);
                    });
                });
            });
        });
    });
})
</script>
{include file='_footer'}